//package com.t2two.myproject.projects;
//
//import com.alibaba.fastjson.JSONObject;
//import com.haijiaonet.workbenchserver.feign.MessageService;
//import com.nbzlth.utils.entity.message.MsgContentDto;
//import com.nbzlth.utils.enums.MsgBusinessCodeEnum;
//import com.nbzlth.utils.enums.MsgRelationTypeEnum;
//import com.nbzlth.utils.enums.MsgTypeExchangeRoutingEnum;
//import com.nbzlth.utils.enums.SendTypeEnum;
//import org.apache.commons.collections.CollectionUtils;
//import org.apache.commons.collections.MapUtils;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.PostConstruct;
//import java.util.Date;
//import java.util.List;
//import java.util.Map;
//import java.util.Objects;
//
///**
// * @version 1.0
// * @description: 统一的消息发送
// * @author: lifei
// * @date: 2024/7/12 11:32
// */
//@Component
//public class WholeSendMsgService {
//    @Autowired
//    private MessageService messageService;
//
//    private static MessageService staticMessageService;
//
//    @PostConstruct
//    private void initWholeSendMsgServiceBean(){
//        staticMessageService = messageService;
//    }
//
//    public static void sendMsg2UserIds(MsgBusinessCodeEnum businessCodeEnum, String formId, String msgType, List<Integer> userIdList, Map hashMap,Boolean queryTemplate){
//        if(Objects.isNull(businessCodeEnum) || StringUtils.isBlank(formId) || StringUtils.isBlank(msgType)){
//            return;
//        }
//        if(Objects.isNull(queryTemplate)){
//            queryTemplate = Boolean.TRUE;
//        }
//        MsgContentDto msgContentDto = new MsgContentDto();
//        msgContentDto.setQueryTemplate(queryTemplate);
//        msgContentDto.setIsFinish(Boolean.TRUE);
//        msgContentDto.setMsgType(msgType);
//        msgContentDto.setTitle(businessCodeEnum.getTitle());
//        msgContentDto.setContent(MapUtils.isEmpty(hashMap)?"": JSONObject.toJSONString(hashMap));
//        msgContentDto.setSender("0");
//        msgContentDto.setUserIds(CollectionUtils.isNotEmpty(userIdList)?StringUtils.join(userIdList,","):null);
//        msgContentDto.setCreateTime(new Date());
//        msgContentDto.setUpdateTime(new Date());
//        msgContentDto.setSendType(SendTypeEnum.NOW.getKey());
//        msgContentDto.setStartSendTime(new Date());
//        msgContentDto.setBusinessCode(businessCodeEnum.getCode());
//        // 通知消息
//        if(MsgTypeExchangeRoutingEnum.notice.getMsgType().equals(msgType)){
//            msgContentDto.setIsValid(Boolean.FALSE);
//        }else if(MsgTypeExchangeRoutingEnum.system.getMsgType().equals(msgType)){
//            msgContentDto.setIsValid(Boolean.FALSE);
//        }else if(MsgTypeExchangeRoutingEnum.business.getMsgType().equals(msgType)){
//            msgContentDto.setIsValid(Boolean.TRUE);
//            msgContentDto.setIsFinish(Boolean.FALSE);
//        }else if(MsgTypeExchangeRoutingEnum.remind.getMsgType().equals(msgType)){
//            msgContentDto.setIsValid(Boolean.FALSE);
//        }else if(MsgTypeExchangeRoutingEnum.other.getMsgType().equals(msgType)){
//            msgContentDto.setIsValid(Boolean.FALSE);
//        }else {
//            msgContentDto.setIsValid(Boolean.FALSE);
//        }
//        msgContentDto.setRelationType(MsgRelationTypeEnum.business.getKey());
//        msgContentDto.setForeignGuid(formId);
//        staticMessageService.addOrUpdateMsgContentAndSend(msgContentDto);
//    }
//}
